/**
 * 2010(c) Copyright Oceansoft Information System Co.,LTD. All rights reserved.
 * <p>
 * Compile: JDK1.6+
 * <p>
 * 鐗堟潈鎵�湁(C)锛氭睙鑻忔绱㈣蒋浠舵湁闄愬叕鍙�
 * <p>
 * 鍏徃鍚嶇О锛氭睙鑻忔绱㈣蒋浠舵湁闄愬叕鍙�
 * <p>
 * 鍏徃鍦板潃锛氳嫃宸炴柊鍖洪潚灞辫矾1鍙风储杩疄璁熀鍦�
 * <p>
 * 缃戝潃: http://www.oceansoft.com.cn
 * <p>
 * 鐗堟湰: 鏉冨姏闃冲厜鏁版嵁绠＄悊骞冲彴_1.0
 * <p>
 * 浣滆�: 110510(鏈变紵瀹�
 * <p>
 * <p>
 * 鏂囦欢鍚� SendSMS.java
 * <p>
 * 绫讳骇鐢熸椂闂�2012-12-6 涓嬪崍4:22:01
 * <p>
 * 璐熻矗浜� 110510(鏈变紵瀹�
 * <p>
 * 鎵�湪缁� 鏉冨姏闃冲厜鏁版嵁绠＄悊骞冲彴
 * <p>
 * 鎵�湪閮ㄩ棬: 寮�彂涓�儴-鎶�湳浜岄儴
 * <p>
 * email锛歾huwj@oceansoft.com.cn
 * <p>
 * <p>
 */
/**
 * 鐭俊鍙戦�
 */
package com.oceansoft.mobile.econsole.task.sms;

import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ServiceUtil {

    private static String ENDPOINT;
    private static String METHOD;
    private static String SYSID;
    private static String PP_SECRE;
    private static String ISSENDSMS;


    static {
        ENDPOINT = "http://10.35.252.76:8080/jxt/services/ntxService";
        SYSID = "1000";
        PP_SECRE = "xAZlzOQKSoABXaWJZdd4wA==";
        METHOD = "queryGrdhByDeptIdKey";
        //ISSENDSMS = CommonUtilCache.getPropValue("isSendSMS");
        /*try{
            String filename = HuiCommonUtilCache.getCommonUtil(HuiCommonUtilCache.KEY_WebRealPath)+"/WEB-INF/classes/config/config.properties";
			//System.out.println("鏂囦欢璺緞:"+filename);
			File f = new File(filename);
			InputStream in = new FileInputStream(f);
			Properties p = new Properties();
			p.load(in);
			URL = p.getProperty("openfire");
			ENDPOINT = p.getProperty("endpoint");
			SYSID = p.getProperty("sysid");
			PP_SECRE = p.getProperty("app_secret");
			SSO = p.getProperty("sso");
			}catch (Exception e) {
				e.printStackTrace();
			}*/
    }

    public static void sendSMS(String message, String policeNum,
                               String receivers) {
        //ENDPOINT = "http://localhost:8080/uums/services/smsService";
        //if ("1".equals(ISSENDSMS)) {

//		String appId, String secretKey, String receiver,
//		String title, String content, String sysName, String appUrl

        //businesspk=1&appId=507&moduleId=&type=1&receiveNos=18112605079&message=111

        try {
            org.apache.axis.client.Service service1 = new org.apache.axis.client.Service();
            String endPoint = ENDPOINT;// "http://192.168.49.43/uums/services/messageService";

            Call call = (Call) service1.createCall();
            call.setTargetEndpointAddress(endPoint);
            call.setOperationName(new QName(METHOD));
            call.addParameter("deptId",
                    org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);
            call.addParameter("key",
                    org.apache.axis.encoding.XMLType.XSD_STRING,
                    javax.xml.rpc.ParameterMode.IN);
                /*	call.addParameter("moduleId",
                        org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);
				call.addParameter("type",
						org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);
				call.addParameter("receiveNos",
						org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);
				call.addParameter("message",
						org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);
				call.addParameter("appUrl",
						org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);*/
				
			/*	call.addParameter("startDate",
						org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);
				call.addParameter("endDate",
						org.apache.axis.encoding.XMLType.XSD_STRING,
						javax.xml.rpc.ParameterMode.IN);*/

            // service1.createCall();
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
				
				/*
				  <xsd:element maxOccurs="1" minOccurs="1" name="appId" nillable="true" type="xsd:string" /> 
				  <xsd:element maxOccurs="1" minOccurs="1" name="secretKey" nillable="true" type="xsd:string" /> 
				  <xsd:element maxOccurs="1" minOccurs="1" name="receiver" nillable="true" type="xsd:string" /> 
				  <xsd:element maxOccurs="1" minOccurs="1" name="title" nillable="true" type="xsd:string" /> 
				  <xsd:element maxOccurs="1" minOccurs="1" name="content" nillable="true" type="xsd:string" /> 
				  <xsd:element maxOccurs="1" minOccurs="1" name="sysName" nillable="true" type="xsd:string" /> 
				  <xsd:element maxOccurs="1" minOccurs="1" name="appUrl" nillable="true" type="xsd:string" /> 

				*/


            int result = 0;
            // call.setUseSOAPAction(true);
            Object[] params = new Object[2];
            params[0] = "536";//SYSID;
            params[1] = "张";

            Date d = new Date();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");


//				params[2] = "20140814183341";
//				params[3] = "20140814193241";
//				params[4] = "18112605079";
//				params[5] = "绯荤粺鍚嶇О";
//				params[6] = "http://10.35.252.75:9080/lczz";
            ServiceThread t = new ServiceThread(call, params);
            t.start();
            //result = (Integer) call.invoke(params);
            //System.out.println("response=" + result);

        } catch (Exception e) {
            e.printStackTrace();
        }
        //}
    }


}
